<%@ page session="false" contentType="text/html;charset=utf-8"%>

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@include file="inc/head.inc"%>
<f:view>
	<f:loadBundle basename="forum.util.messages.MessageResource" var="msg" />

	<h:form id="form">
		<h:panelGrid id="grid" columns="3" title="#{msg['headerTitle']}">
			<f:facet name="header">
				<h:outputText value="#{msg['headerTitle']}" />
			</f:facet>

			<h:outputText id="outputFirstName" value="#{msg['first_name']}" />
			<h:inputText id="inputFirstName" value="#{userDataBean.name}"
				required="true">
				<f:validateLength minimum="2" maximum="20" />
			</h:inputText>
			<h:message id="firstNameError" for="inputFirstName" styleClass="error"/>

			<h:outputText id="outputSurname" value="#{msg['surname']}" />
			<h:inputText id="inputSurname" value="#{userDataBean.surname}"
				required="true" />
			<h:message id="surnameError" for="inputSurname" styleClass="error"/>


			<h:outputText id="inputSex" value="#{msg['sex']}" />
			<h:selectOneRadio id="choiceSex" value="#{userDataBean.isFemale}" required="true">
				<f:selectItem itemValue="0" itemLabel="#{msg['female']}" />
				<f:selectItem itemValue="1" itemLabel="#{msg['male']}" />
			</h:selectOneRadio>
			<h:message id="sexError" for="choiceSex" styleClass="error"/>


			<h:outputText id="outputBirthday" value="#{msg['birthday']}" />
			<h:panelGrid id="gridBirthday" columns="3">
				<h:outputLabel for="inputDay" value="#{msg['day']}" />
				<h:outputLabel for="inputMonth" value="#{msg['month']}" />
				<h:outputLabel for="inputYear" value="#{msg['year']}" />
				<h:selectOneMenu value="#{userDataBean.day}" id="inputDay">
					<f:selectItems value="#{calendarValues.days}" />
				</h:selectOneMenu>
				<h:selectOneMenu value="#{userDataBean.month}" id="inputMonth">
					<f:selectItems value="#{calendarValues.months}" />
				</h:selectOneMenu>
				<h:selectOneMenu value="#{userDataBean.year}" id="inputYear">
					<f:selectItems value="#{calendarValues.years}" />
				</h:selectOneMenu>
			</h:panelGrid>
			<h:panelGroup />

			<h:outputText id="outputCity" value="#{msg['city']}" />
			<h:inputText id="inputCity" value="#{userDataBean.city}" required="true" />
			<h:message id="cityError" for="inputCity" styleClass="error"/>

			<h:outputText id="outputCountry" value="#{msg['country']}" />
			<h:inputText id="inputCountry" value="#{userDataBean.country}" required="true" />
			<h:message id="countryError" for="inputCountry" styleClass="error"/>

			<h:outputText id="outputLogin" value="#{msg['login']}" />
			<h:inputText id="inputLogin" value="#{userDataBean.login}"  required="true" />
			<h:message id="loginError" for="inputLogin" styleClass="error"/>

			<h:outputText id="outputPassword" value="#{msg['password']}" />
			<h:inputText id="inputPassword" value="#{userDataBean.password}" required="true" />
			<h:message id="passwordError" for="inputPassword" styleClass="error"/>

			<h:outputText id="outputRepeatPassword"
				value="#{msg['repeatPassword']}" />
			<h:inputText id="inputRepeatPassword" required="true" >
				<t:validateEqual for="inputPassword" />
			</h:inputText>	
			<h:message id="repeatPasswordError" for="inputRepeatPassword" styleClass="error"/>

			<h:outputText id="outputEmail" value="#{msg['e-mail']}" />
			<h:inputText id="inputEmail" value="#{userDataBean.email}" required="true">
				<t:validateEmail />
			</h:inputText>	
			<t:message id="emailError" for="inputEmail" styleClass="error"/>


			<h:outputText id="outputStatus" value="#{msg['status']}" />
			<h:selectOneMenu id="inputStatus" required="true" value="#{userDataBean.status}">
				<f:selectItem itemValue="0" itemLabel="#{msg['user']}" />
				<f:selectItem itemValue="1" itemLabel="#{msg['moderator']}" />
				<f:selectItem itemValue="2" itemLabel="#{msg['administrator']}" />
			</h:selectOneMenu>
			<h:panelGroup />

			<h:panelGroup />
			<h:commandButton id="validateButton" value="#{msg['button_save']}" action="success" > 
				<f:actionListener type="forum.view.listeners.user.CreateUserListener" />
			</h:commandButton>
			<h:panelGroup />
		</h:panelGrid>
	</h:form>
</f:view>
